import { createRouter, createWebHashHistory } from 'vue-router'

import Login from '../views/Login/index.vue'
import Register from '../views/Register/index.vue'
import Home from '../views/Home/index.vue'
import HomeIndex from '../views/Home/HomeIndex.vue'
import SellBooks from '../views/Home/SellBooks.vue'
import ShopCar from '../views/Home/ShopCar.vue'
import Mine from '../views/Home/Mine.vue'
import NotFound from '../views/NotFound.vue'

const routes = [
    {
        path: '/',
        redirect: '/login',  // 重定向:重新指向其它path,会改变网址
    },
    {
        path: '/login',
        component: Login
    },
    {
        path: '/register',
        component: Register
    },
    {
        path: '/home',
        component: Home,
        children: [
            {
                path: '/home',
                redirect: '/homeIndex',  // 重定向:重新指向其它path,会改变网址
            },
            {
                path: '/homeIndex',
                component: HomeIndex
            },
            {
                path: '/sellBooks',
                component: SellBooks
            },
            {
                path: '/shopCar',
                component: ShopCar
            },
            {
                path: '/mine',
                component: Mine
            }
        ]
    },
    {
        path: '/:pathMatch(.*)',
        component: NotFound
    }
]




const router = createRouter({
    history: createWebHashHistory(),
    routes
})

export default router